<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'pid'=>0);
	$user_juese=$this->user_juese;
	$list=array();
	foreach($user_juese as $key=>$title){
		$item=pdo_get('jy_yxgz_feeset',array('uniacid'=>$_SESSION['uniacid'],'juese'=>$key));
		if(!$item['id']){
			pdo_insert('jy_yxgz_feeset',array('uniacid'=>$_SESSION['uniacid'],'juese'=>$key));
			$item=pdo_get('jy_yxgz_feeset',array('uniacid'=>$_SESSION['uniacid'],'juese'=>$key));
		}
		$item['title']=$title;
		$item['shifeeset']=json_decode($item['shifeeset'],true);
		$item['feeset']=json_decode($item['feeset'],true);
		$list[]=$item;
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'薪资管理'),
		),
		'list'=>array('data'=>'list','tip'=>'【温馨提示】：实习薪资待遇，转正薪资待遇！','del_one'=>false,'delall'=>false,'list'=>array(			
			array('name'=>'title','title'=>'角色名称','type'=>'string'),
			array('name'=>'shifeeset.jifee','title'=>'实习基本工资','type'=>'string'),
			array('name'=>'feeset.jifee','title'=>'转正基本工资','type'=>'string'),	
		)),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='edit'){
	$id=intval($_RQ['id']);
	if($id){
		$item=pdo_get('jy_yxgz_feeset',array('id'=>$id));
	}else{
		$item=array();
	}
	$item['title']=$this->user_juese[$item['juese']];
	$item['shifeeset']=json_decode($item['shifeeset'],true);
	$item['feeset']=json_decode($item['feeset'],true);
	$item['yjfeeset1']=$item['shifeeset']['yjfeeset'];
	$item['tcfeeset1']=$item['shifeeset']['tcfeeset'];
	$item['yjfeeset2']=$item['feeset']['yjfeeset'];
	$item['tcfeeset2']=$item['feeset']['tcfeeset'];
    $return['item']=$item;	
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'desc'=>'职位设置',
		'tabs'=>array(
			array('op'=>'list','title'=>'职位管理'),
		),
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'实习薪资待遇',
				'list'=>array(
					array('name'=>'title','title'=>'所属角色','type'=>'string','read'=>true),
					array('name'=>'shifeeset.jifee','title'=>'基本工资','type'=>'unitstring','unit'=>'元'),
					array('name'=>'shifeeset.kqfee','title'=>'出勤奖励','type'=>'unitstring','unit'=>'元','help'=>'如果是满勤，那就有出勤奖励'),
					array('name'=>'shifeeset.bzfee','title'=>'补助绩效','type'=>'unitstring','unit'=>'元','help'=>'可以录入绩效奖励条件或全勤时获得奖励'),
					array('name'=>'shifeeset.bzmanfee','title'=>'满多少业绩获得补助绩效','type'=>'unitstring','unit'=>'元'),
					array('type'=>'array','title'=>'业绩绩效','name'=>'yjfeeset1','add_tip'=>'添加一个阶梯',
									'list'=>array(
										array('type'=>'unitstring','unit'=>'元','name'=>'man','title'=>'业绩满多少'),
										array('type'=>'unitstring','unit'=>'元','name'=>'fee','title'=>'奖励N元'),						
									),
									'details'=>array(
										array('type'=>'unitstring','unit'=>'元','name'=>'man','title'=>'业绩满多少'),
										array('type'=>'unitstring','unit'=>'元','name'=>'fee','title'=>'奖励N元'),	
									)
					),
					array('type'=>'array','title'=>'提成工资','name'=>'tcfeeset1','add_tip'=>'添加一个阶梯',
									'list'=>array(
										array('type'=>'unitstring','unit'=>'元','name'=>'min','title'=>'业绩起'),
										array('type'=>'unitstring','unit'=>'元','name'=>'max','title'=>'至业绩'),
										array('type'=>'unitstring','unit'=>'%','name'=>'rate','title'=>'提成%'),						
									),
									'details'=>array(
										array('type'=>'unitstring','unit'=>'元','name'=>'min','title'=>'业绩起'),
										array('type'=>'unitstring','unit'=>'元','name'=>'max','title'=>'至业绩'),
										array('type'=>'unitstring','unit'=>'%','name'=>'rate','title'=>'提成%'),	
									)
					),
					array('name'=>'shifeeset.she1fee','title'=>'社保-养老','type'=>'unitstring','unit'=>'元'),
					array('name'=>'shifeeset.she2fee','title'=>'社保-医疗','type'=>'unitstring','unit'=>'元'),
					array('name'=>'shifeeset.she3fee','title'=>'社保-失业','type'=>'unitstring','unit'=>'元'),
					array('name'=>'shifeeset.gjjfee','title'=>'公积金','type'=>'unitstring','unit'=>'元'),
				)
			),
			array(
				'title'=>'转正薪资待遇',
				'list'=>array(
					array('name'=>'title','title'=>'所属角色','type'=>'string','read'=>true),
					array('name'=>'feeset.jifee','title'=>'基本工资','type'=>'unitstring','unit'=>'元'),
					array('name'=>'feeset.kqfee','title'=>'出勤奖励','type'=>'unitstring','unit'=>'元','help'=>'如果是满勤，那就有出勤奖励'),
					array('name'=>'feeset.bzfee','title'=>'补助绩效','type'=>'unitstring','unit'=>'元','help'=>'可以录入绩效奖励条件或全勤时获得奖励'),
					array('name'=>'feeset.bzmanfee','title'=>'满多少业绩获得补助绩效','type'=>'unitstring','unit'=>'元'),
					array('type'=>'array','title'=>'业绩绩效','name'=>'yjfeeset2','add_tip'=>'添加一个阶梯',
									'list'=>array(
										array('type'=>'unitstring','unit'=>'元','name'=>'man','title'=>'业绩满多少'),
										array('type'=>'unitstring','unit'=>'元','name'=>'fee','title'=>'奖励N元'),						
									),
									'details'=>array(
										array('type'=>'unitstring','unit'=>'元','name'=>'man','title'=>'业绩满多少'),
										array('type'=>'unitstring','unit'=>'元','name'=>'fee','title'=>'奖励N元'),	
									)
					),
					array('type'=>'array','title'=>'提成工资','name'=>'tcfeeset2','add_tip'=>'添加一个阶梯',
									'list'=>array(
										array('type'=>'unitstring','unit'=>'元','name'=>'min','title'=>'业绩起'),
										array('type'=>'unitstring','unit'=>'元','name'=>'max','title'=>'至业绩'),
										array('type'=>'unitstring','unit'=>'%','name'=>'rate','title'=>'提成%'),						
									),
									'details'=>array(
										array('type'=>'unitstring','unit'=>'元','name'=>'min','title'=>'业绩起'),
										array('type'=>'unitstring','unit'=>'元','name'=>'max','title'=>'至业绩'),
										array('type'=>'unitstring','unit'=>'%','name'=>'rate','title'=>'提成%'),	
									)
					),
					array('name'=>'feeset.she1fee','title'=>'社保-养老','type'=>'unitstring','unit'=>'元'),
					array('name'=>'feeset.she2fee','title'=>'社保-医疗','type'=>'unitstring','unit'=>'元'),
					array('name'=>'feeset.she3fee','title'=>'社保-失业','type'=>'unitstring','unit'=>'元'),
					array('name'=>'feeset.gjjfee','title'=>'公积金','type'=>'unitstring','unit'=>'元'),
				)
			),			
		)
	);
	$return['role_type']=$this->role_type;
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	$id=intval($postdata['id']);
	$postdata['shifeeset']['yjfeeset']=$postdata['yjfeeset1'];
	$postdata['shifeeset']['tcfeeset']=$postdata['tcfeeset1'];
	$postdata['feeset']['yjfeeset']=$postdata['yjfeeset2'];
	$postdata['feeset']['tcfeeset']=$postdata['tcfeeset2'];
	$data=array();
	$data['feeset']=ijson_encode($postdata['feeset']);
	$data['shifeeset']=ijson_encode($postdata['shifeeset']);
	$gourl='/group/list/';
	if($id){
		pdo_update('jy_yxgz_feeset',$data,array('id'=>$id));
		exi('设置成功！','',$gourl);
	}else{
		$data['uniacid']=$_SESSION['uniacid'];
		pdo_insert('jy_yxgz_feeset',$data);
		exi('添加成功！','',$gourl);
	}
}
?>